package com.indusfo.spc.controller;

import com.indusfo.spc.aspect.SystemControllerLog;
import com.indusfo.spc.pojo.ProcessExchange;
import com.indusfo.spc.service.ProcessExchangeService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @ProjectName: IEIS2-COM
 * @Package: com.indusfo.spc.controller
 * @ClassName: ProcessExchangeController
 * @Author: 熊冰
 * @Description: 流程维修下线表 接口
 * @Date: 2019/9/4 16:44
 * @Version: 1.0
 */
@Controller
@RequestMapping("/processExchange")
public class ProcessExchangeController {
    @Autowired
    private ProcessExchangeService processExchangeService;

    /**
     * 修改不良对策
     *
     * @param processExchange
     * @return
     */
    @RequestMapping(value = "/updateProcessExchange",method= RequestMethod.POST)
    @SystemControllerLog(description="修改不良对策")
    @ResponseBody
    public JSONObject updateProcessExchange (ProcessExchange processExchange){

        JSONObject json=processExchangeService.updateProcessExchange(processExchange);

        return json;
    }

    /**
     * 查询
     *
     * @param
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/queryProcessExchange")
    @SystemControllerLog(description="查询不良对策")
    @ResponseBody
    public JSONObject queryDep(ProcessExchange processExchange) {

        JSONObject json = processExchangeService.queryProcessExchange(processExchange);
        return json;

    }

    /**
     * 插入
     *
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/insertProcessExchange", method= RequestMethod.POST)
    @SystemControllerLog(description="新增不良对策")
    @ResponseBody
    public JSONObject insertProcessExchange(ProcessExchange processExchange) {

        JSONObject json = processExchangeService.insertProcessExchange(processExchange);
        return json;
    }

    /**
     * 启用/停用
     *
     * @param processExchangeIds, dataState
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/definesProcessExchange", method= RequestMethod.POST)
    @SystemControllerLog(description="启用/停用不良对策")
    @ResponseBody
    public JSONObject definesProcessExchange(@RequestParam("processExchangeIds")List<Integer> processExchangeIds, Integer dataState) {

        JSONObject json = processExchangeService.deleteProcessExchange(processExchangeIds, dataState);
        return json;
    }

    /**
     * 删除
     *
     * @param processExchangeIds, dataState
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/deleteProcessExchange", method= RequestMethod.POST)
    @SystemControllerLog(description="删除不良对策")
    @ResponseBody
    public JSONObject deleteProcessExchange(@RequestParam("processExchangeIds")List<Integer> processExchangeIds, Integer dataState) {

        dataState = 2;
        JSONObject json = processExchangeService.deleteProcessExchange(processExchangeIds, dataState);
        return json;
    }

    /**
     * 批量新增
     *
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/batchInsertProcessExchange", method= RequestMethod.POST)
    @SystemControllerLog(description="新增不良对策")
    @ResponseBody
    public JSONObject batchInsertProcessExchange(@RequestParam("lProFlows")List<Integer> lProFlows, Integer lProVer,Integer offlineId) {

        JSONObject json = processExchangeService.batchInsertProcessExchange(lProFlows,lProVer,offlineId);
        return json;
    }
}
